
local function event_handler( e )

	local code = lv.event_get_code( e );

	local obj = lv.event_get_target( e );

	if code == lv.LV_EVENT_VALUE_CHANGED then

		local id = lv.btnmatrix_get_selected_btn( obj );

		local txt = lv.btnmatrix_get_btn_text( obj, id );

		print( string.format( "%s was pressed", txt ) );
	end
end

local btnm_map = lv.btnmatrix_gen_string_list(

	"1", "2", "3", "4", "5", "\n",
	"6", "7", "8", "9", "0", "\n",
	"Action1", "Action2"
)

local btnm1 = lv.btnmatrix_create( lv.scr_act() );

lv.btnmatrix_set_map( btnm1, btnm_map );

lv.btnmatrix_set_btn_width( btnm1, 10, 2 );

lv.btnmatrix_set_btn_ctrl( btnm1, 10, lv.LV_BTNMATRIX_CTRL_CHECKABLE );

lv.btnmatrix_set_btn_ctrl( btnm1, 11, lv.LV_BTNMATRIX_CTRL_CHECKED );

lv.obj_align( btnm1, lv.LV_ALIGN_CENTER, 0, 0 );

lv.obj_add_event_cb( btnm1, lv.LV_EVENT_ALL, event_handler );
